<template>
  <!-- background-color="#545c64"
  text-color="#fff"-->
  <div>
    <el-container class="bg">
      <el-aside width="200px">
        <el-menu
          class="el-menu-vertical-demo"
          text-color="#fff"
          active-text-color="#ffd04b"
          router
          unique-opened
        >
          <el-menu-item index="/index/home">
            <i class="el-icon-menu"></i>
            <span slot="title">首页</span>
          </el-menu-item>
          <div v-for=" item in user.menus" :key="item.id">
            <el-submenu :index="item.id+''" v-if="item.children">
              <template slot="title">
                <i class="el-icon-setting"></i>
                <span>{{item.title}}</span>
              </template>
              <el-menu-item-group v-for=" i in item.children" :key="i.id">
                <el-menu-item :index="'/index'+i.url">{{i.title}}</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-menu-item-group :index="item.id+''" v-else>
              <el-menu-item :index="'/index'+item.url">{{item.title}}</el-menu-item>
            </el-menu-item-group>
          </div>
        </el-menu>
      </el-aside>
      <el-container>
        <el-header>
          <el-button @click="exit">登出</el-button>
          <i class="el-icon-setting fr"></i>
          <span class="name fr">{{user.username}}</span>
        </el-header>
        <el-main>
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>{{this.$route.meta.title}}</el-breadcrumb-item>
          </el-breadcrumb>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapGetters({
      user: "user"
    })
  },
  methods: {
    ...mapActions({
      changeuser: "changeuser"
    }),
    exit() {
      this.changeuser({});
      this.$router.push("/");
    }
  },
  mounted() {}
};
</script>

<style lang="less" scoped>
@import "../../less/index.less";
.bg {
  height: 100vh;
  .el-aside,
  .el-menu,
  .el-menu-item-group {
    background: @primary;
  }
  /deep/.el-submenu__title:hover,
  .el-menu-item:focus,
  .el-menu-item:hover {
    background: @color1;
  }
  .el-header {
    background: @info;
  }
  .el-icon-setting,
  .name {
    line-height: 60px;
    margin-left: 5px;
  }
}
</style>